package easyway.trainapp.webframework.web;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;


public class HeadingConverter  implements Converter {

	public Object getAsObject(FacesContext context, UIComponent component, String value){
    	return null;
    }

	/*
	 * zhangdongsheng
	 * 截取字符串长度转换器
	 */
	
    public String getAsString(FacesContext context, UIComponent component, Object value){
    	StringBuilder headingString;
    	if (value.toString().length() !=0 && value.toString().length()>=Constant.STRING_LENGTH ){
            headingString = new StringBuilder();
            headingString.append(value.toString().substring(0, Constant.STRING_LENGTH));  
            return headingString.toString()+"...";
        }
        return value.toString();
    } 
}
